const app = getApp()

Page({
  onShareAppMessage() {
    return {
      title: 'scroll-view',
      path: 'page/component/pages/scroll-view/scroll-view'
    }
  },

  data: {
    toView: 'green',
    inputValue: '',
    date: '2016-09-01',
    name: '',
    age: '',
    url: 'https://api.imjad.cn/cloudmusic/?type=lyric&id=28012031',
    userAge: app.globalData.userAge,
    arr1: [1,2,3,4]
  },
  onLoad(e) {
    this.setData({
      name: e.name,
      age: e.age
    })
  },
  upper(e) {
    console.log(e)
  },

  lower(e) {
    console.log(e)
  },

  scroll(e) {
    console.log(e)
  },

  scrollToTop() {
    this.setAction({
      scrollTop: 0
    })
  },

  tap() {
    for (let i = 0; i < order.length; ++i) {
      if (order[i] === this.data.toView) {
        this.setData({
          toView: order[i + 1],
          scrollTop: (i + 1) * 200
        })
        break
      }
    }
  },

  tapMove() {
    this.setData({
      scrollTop: this.data.scrollTop + 10
    })
  },
  // 获取输入框的值，并显示在view中
  bindKeyInput: function (e) {
    this.setData({
      inputValue: e.detail.value
    })
    app.globalData.userAge = e.detail.value
  },
  // 修改日期选择器
  bindDateChange(e) {
    console.log(e.detail.value)
    this.setData({
      date: e.detail.value
    })
  },
  getInfo() {
    wx.request({
      url: 'https://api.imjad.cn/cloudmusic/?type=lyric&id=28012031',
      method: 'GET',
      success: res => {
        console.log(res.data.lrc.version)
        wx.showToast({ // 显示Toast
          title: `歌词版本：${res.data.lrc.version}`,
          icon: 'success',
          duration: 1500
        })
      }
    })
  },
  // 处理子组件发射的自定义事件
  changeHandler(e) {
    console.log(`子组件传过来的值：${e.detail}`)
  }
})